FROM python:3.6
LABEL maintainer=lh1993

ENV PROD_PATH /app/SkyWalkingWeb

RUN yum clean all &&\
    yum -y install mysql-devel wget net-tools make gcc gcc-c++ gcc-devel python3-devel libffi-devel libevent-devel &&\
    mkdir -p $PROD_PATH/WeChat;\
    mkdir -p $PROD_PATH/SkyWalkingWeb;\
    mkdir -p $PROD_PATH/common;\
    mkdir -p /app/config/

COPY WeChat $PROD_PATH/WeChat/
COPY SkyWalkingWeb $PROD_PATH/SkyWalkingWeb/
COPY common $PROD_PATH/common/
COPY db.sqlite3 manage.py requirement.txt $PROD_PATH/

RUN ls -la $PROD_PATH/* ;\
    cd $PROD_PATH ;\
    pip3 install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple;\
    pip3 install -r requirement.txt -i https://pypi.tuna.tsinghua.edu.cn/simple

# 下载源码
RUN wget https://www.sqlite.org/2019/sqlite-autoconf-3290000.tar.gz ;\
    tar zxvf sqlite-autoconf-3290000.tar.gz ;\
    cd sqlite-autoconf-3290000/ ;\
    ./configure --prefix=/usr/local ;\
    make && make install ;\
    mv /usr/bin/sqlite3  /usr/bin/sqlite3_old ;\
    ln -s /usr/local/bin/sqlite3   /usr/bin/sqlite3 ;\
    echo "/usr/local/lib" > /etc/ld.so.conf.d/sqlite3.conf ;\
    ldconfig ;\
    sqlite3 -version

EXPOSE 9090/tcp
WORKDIR $PROD_PATH

CMD cp /app/config/config.ini $PROD_PATH && export PYTHONIOENCODING=utf-8 && python3 manage.py runserver 0.0.0.0:9090
